﻿
namespace Skynet.ServiceImplementation
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using System.ServiceModel.Activation;
    using Microsoft.Practices.Unity;
    using Skynet.BusinessEntities;

    // TODO: Create methods containing your application logic.
    [EnableClientAccess()]
    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class SkynetDomainService : DomainService
    {   
     
        [Dependency]
        public BusinessLogic.BusinessComponents.IBCExams BCExams { protected get; set; }

        [Dependency]
        public BusinessLogic.BusinessComponents.IBCExamQueries BCExamQueries { get; set; }

        public IQueryable<BusinessEntities.ExamCategory> GetExamCategories()
        {
            return this.BCExamQueries.SearchExamCategories().AsQueryable();            
        }
        public IQueryable<BusinessEntities.Exam> GetExam()
        {
            return this.BCExamQueries.SearchExams().AsQueryable();            
        }

        public void InsertExamCategories(BusinessEntities.ExamCategory examCategory)
        {
            examCategory.MarkAsAdded();
            this.BCExams.MaintenanceExamCategories( new List<BusinessEntities.ExamCategory>(){ examCategory});
        }
        public void DeleteExamCategories(BusinessEntities.ExamCategory examCategory)
        {
                examCategory.MarkAsDeleted();
            this.BCExams.MaintenanceExamCategories(new List<BusinessEntities.ExamCategory>() { examCategory }); 
        }
        public void UpdateExamCategories(BusinessEntities.ExamCategory examCategory)
        {
            examCategory.MarkAsModified();
            this.BCExams.MaintenanceExamCategories(new List<BusinessEntities.ExamCategory>() { examCategory });
        }
        public override bool Submit(ChangeSet changeSet)
        {
            return base.Submit(changeSet);
        }
    }
}


